home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / txt89a.zip / TXT89A.ASM next >
Assembly Source File  |  1990-09-08  |  14KB  |  408 lines

  1. ;TXT89a.ASM (c) Copyright 1990 Lawrence Gozum & Marvin Gozum, MD.
  2.  
  3. ;Greeting GIF Developers !
  4.  
  5. ;The GIF 89a standard poses some very difficult specs for decoders to
  6. ;conform with.  One of them is the VARIABLE character display which
  7. ;can range from 1x1 chracters to 256x256 characters <sheesh>.
  8.  
  9. ;Anyway, with this routine you can point CHARseg and CHARptr to ANY
  10. ;bitmap character set you desire.  In its present form, it will support
  11. ;8x256 character definitions.  You will have to do some tweaking to get
  12. ;256x256 character definitions as indicated in relevant segments below.
  13.  
  14. ;The algorithm and routine presented here will be used in an updated
  15. ;version of MVGAVU which will support GIF 89a decoding as well as a
  16. ;new utility called GIFONT which will miximize text manipulation and
  17. ;utilization of the numerous Public Domain bitmap fonts in BBSs.
  18.  
  19. ;This code (ie., TXT89A.ASM) is hereby released to the Public Domain and
  20. ;can be used anywhere and by anyone in ANY fashion they choose.  We hope
  21. ;this will encourage the acceleration of GIF89a decoder development.  
  22. ;A little acknowldegement of its use or variation of its use would be
  23. ;more than appreciated.
  24.  
  25. ;This code is easily ported to 'C' applications.  All you have to do is
  26. ;change the stack passing parameters to 'C' format.
  27.  
  28. ;Enjoy.
  29.  
  30. ;lawrence - 09 September 1990
  31.  
  32.  
  33. data    segment byte    public  'data'  ;1
  34.  
  35. x               dw      ?
  36. y               dw      ?
  37. xreset          dw      ?
  38. char            dw      ?
  39.  
  40. line            db      ?
  41. i               db      ?
  42.  
  43. tcolor          db      ?
  44. bcolor          db      ?
  45. fcolor          db      ?
  46.  
  47. cxtbl   db      256     dup(?)
  48.  
  49. Charseg dw      ?
  50. Charptr dw      ?
  51. Charloc dw      ?
  52. Chartmp dw      ?
  53.  
  54. CharW   db      ?
  55. CharH   db      ?
  56. CharL   db      ?
  57. Ctran   db      ?
  58.  
  59. cy      db      256      dup(?)
  60. c       db      256      dup(?)
  61. cbits   db      256      dup(?)
  62.  
  63. data    ends
  64.  
  65. dgroup  group   data
  66. code    segment byte    public  'code'
  67.                 assume  cs:code,    ds:dgroup
  68.  
  69. chardata        proc    near
  70.                                         ;This routine is a bit wasteful
  71.                                         ;but is very expandable.
  72.  
  73.                                         ;It is structured this way to
  74.                                         ;accomodate character widths
  75.                                         ;up to 256 pixels wide.
  76.                 mov     ax,char
  77.                 mov     cbits[0],al
  78.                 shl     al,1
  79.                 mov     cbits[1],al
  80.                 shl     al,1
  81.                 mov     cbits[2],al
  82.                 shl     al,1
  83.                 mov     cbits[3],al
  84.                 shl     al,1
  85.                 mov     cbits[4],al
  86.                 shl     al,1
  87.                 mov     cbits[5],al
  88.                 shl     al,1
  89.                 mov     cbits[6],al
  90.                 shl     al,1
  91.                 mov     cbits[7],al
  92.  
  93.                 mov     bp,0
  94.                 mov     ah,0
  95. cxloop:         mov     al,cxtbl[bp]
  96.                 mov     di,ax
  97.                 mov     al,cbits[di]
  98.                 mov     c[bp],al
  99.                 inc     bp
  100.                 mov     ax,bp
  101.                 cmp     al,CharW
  102.                 jne     cxloop
  103.                 ret
  104. chardata        endp
  105.  
  106.                 public  CharParms
  107. CharParms       proc    far
  108.                 push    bp
  109.                 mov     bp,sp
  110.                 mov     bx,[bp+18]
  111.                 mov     ax,[bx]         ;segment of character bitmap
  112.                 mov     CHARseg,ax
  113.  
  114.                 mov     bx,[bp+16]
  115.                 mov     ax,[bx]         ;offset of character bitmap
  116.                 mov     CHARptr,ax
  117.  
  118.                 mov     bx,[bp+14]
  119.                 mov     ax,[bx]         ;Character cell width (DESTINATION)
  120.                 mov     CharW,al
  121.  
  122.                 mov     bx,[bp+12]
  123.                 mov     ax,[bx]         ;Character cell height (DESTINATION)
  124.                 mov     CharH,al
  125.  
  126.                 mov     bx,[bp+10]
  127.                 mov     ax,[bx]         ;# of bytes per character fr SOURCE
  128.                 mov     CharL,al
  129.  
  130.                 mov     bx,[bp+8]
  131.                 mov     ax,[bx]         ;transparency flag
  132.                 mov     CTran,al
  133.  
  134.                 mov     bx,[bp+6]
  135.                 mov     ax,[bx]         ;transparency color
  136.                 mov     tcolor,al
  137.  
  138.                 pop     bp
  139.                 ret     14
  140. CharParms       endp
  141.  
  142.                 public  GetCharXpts
  143. GetCharXpts     proc    far             ;This routine get the
  144.                 push    bp              ;interpolated x-axis and
  145.                 mov     bp,sp           ;saves it to cxtbl for fast
  146.                                         ;indexing up to 256 pixels
  147.                                         ;in width per 89a specs.
  148.                 mov     bx,[bp+8]
  149.                 mov     ax,[bx]
  150.                 mov     es,ax
  151.  
  152.                 mov     bx,[bp+6]
  153.                 mov     si,[bx]         ;es:si = QB array of x pts
  154.                 mov     cx,0
  155.  
  156. CXlineloop:     mov     bx,cx
  157.                 shl     bx,1
  158.                 mov     ax,es:[si]
  159.                 mov     bx,cx
  160.                 mov     cxtbl[bx],al
  161.                 inc     si
  162.                 inc     si
  163.                 inc     cx
  164.                 cmp     cx,256
  165.                 jne     CXlineloop
  166.  
  167.                 pop     bp
  168.                 ret     4
  169. GetCharXpts     endp
  170.  
  171.                 public  GetCharYpts
  172. GetCharYpts     proc    far             ;Conversely, this routine
  173.                 push    bp              ;get the 256 interpolated
  174.                 mov     bp,sp           ;y pixels for the Character
  175.                                         ;cell height up to 256 pixels.
  176.                 mov     bx,[bp+8]
  177.                 mov     ax,[bx]
  178.                 mov     es,ax
  179.  
  180.                 mov     bx,[bp+6]
  181.                 mov     si,[bx]         ;es:si = QB array of y pts
  182.                 mov     cx,0
  183.  
  184. CYlineloop:     mov     bx,cx
  185.                 shl     bx,1
  186.                 mov     ax,es:[si]
  187.                 mov     bx,cx
  188.                 mov     cy[bx],al
  189.                 inc     si
  190.                 inc     si
  191.                 inc     cx
  192.                 cmp     cx,256
  193.                 jne     CYlineloop
  194.  
  195.                 pop     bp
  196.                 ret     4
  197. GetCharYpts     endp
  198.  
  199.  
  200.                 public  XVGAtext
  201. XVGAtext        proc    far
  202.                 push    bp
  203.                 mov     bp,sp
  204.  
  205.                 mov     bx,[bp+12]      ;x
  206.                 mov     ax,[bx]
  207.                 mov     x,ax
  208.                 mov     xreset,ax
  209.  
  210.                 mov     bx,[bp+10]
  211.                 mov     ax,[bx]         ;y
  212.                 mov     y,ax
  213.  
  214.                 mov     bx,[bp+8]
  215.                 mov     ax,[bx]         ;foreground color
  216.                 mov     fcolor,al
  217.  
  218.                 mov     bx,[bp+6]
  219.                 mov     ax,[bx]         ;background color
  220.                 mov     bcolor,al
  221.  
  222.                 mov     bx,[bp+14]
  223.                 mov     ax,[bx]         ;actual character (asc value)
  224.                 mov     dx,0
  225.                 mul     CharL
  226.                 add     ax,CHARptr
  227.                 mov     CHARloc,ax
  228.                 mov     CHARtmp,ax
  229.  
  230.                 mov     al,0
  231.                 mov     line,al
  232.                 mov     bl,Ctran
  233.                 cmp     bl,0            ;if transparency flag ON
  234.                 je      charloop2       ;no
  235.                 jmp     charloop2t      ;yes, jump to transparency routines
  236.                                         ;since its too far for jxx offset
  237.  
  238. charloop2:      mov     al,0
  239.                 mov     i,al
  240.                 mov     es,CHARseg
  241.                 mov     si,CHARtmp
  242.                 mov     al,es:[si]
  243.                 mov     char,ax
  244.                 call    chardata
  245.  
  246.                 mov     di,0A000h
  247.                 mov     es,di
  248.                 mov     ax,xreset
  249.                 mov     si,ax
  250.                 mov     di,0
  251.  
  252. charloop1:      mov     al,c[di]
  253.                 and     al,128
  254.                 jz      cbkgrnd
  255.  
  256.                 call    vDUMMY          ;replace this with your
  257.                                         ;video routine or look-up
  258.                                         ;vector to JUMP to ANY
  259.                                         ;video routine
  260.  
  261.  
  262.                 mov     al,fcolor       ;load al w/ foreground color
  263.                 mov     es:[di],al      ;plot it
  264.  
  265. nextcpix:       inc     si
  266.                 inc     i
  267.                 mov     ah,0
  268.                 mov     al,i
  269.                 mov     di,ax
  270.                 cmp     al,CharW
  271.                 jne     charloop1
  272.  
  273.                 inc     Y
  274.                 inc     line
  275.                 mov     ax,CHARloc
  276.                 mov     bl,line
  277.                 mov     bh,0
  278.                 add     al,cy[bx]
  279.                 mov     CHARtmp,ax
  280.                 mov     al,line
  281.                 cmp     al,CharH
  282.                 jne     charloop2
  283.  
  284.                 pop     bp
  285.                 ret     10
  286.  
  287. cbkgrnd:        call    vDUMMY          ;replace this with your
  288.                                         ;video routine or look-up
  289.                                         ;vector to JUMP to ANY
  290.                                         ;video routine
  291.  
  292.                 mov     al,bcolor       ;load al w/ background color
  293.                 mov     es:[di],al      ;plot it
  294.  
  295.                 jmp     short nextcpix
  296.  
  297. charloop2t:     mov     al,0
  298.                 mov     i,al
  299.                 mov     es,CHARseg
  300.                 mov     si,CHARtmp
  301.                 mov     al,es:[si]
  302.                 mov     char,ax         ;use ax for expansion to 16 bits
  303.                                         ;or larger by adding more indices
  304.                                         ;(eg., es:[si+1])
  305.  
  306.                 call    chardata        ;get the bits
  307.  
  308.                 mov     di,0A000h
  309.                 mov     es,di           ;set ES to screen
  310.                 mov     ax,xreset       ;reset x
  311.                 mov     si,ax
  312.                 mov     di,0
  313.  
  314. charloop1t:     mov     al,c[di]
  315.                 and     al,128
  316.                 jz      cbkgrndt
  317.  
  318.                 call    vDUMMY          ;replace this with your
  319.                                         ;video routine or look-up
  320.                                         ;vector to JUMP to ANY
  321.                                         ;video routine
  322.  
  323.                 mov     al,es:[di]
  324.                 cmp     al,tcolor
  325.                 je      nextcpixt
  326.  
  327.                 call    vDUMMY          ;replace this with your
  328.                                         ;video routine or look-up
  329.                                         ;vector to JUMP to ANY
  330.                                         ;video routine
  331.  
  332.  
  333.                 mov     al,fcolor       ;load al w/ foreground color
  334.                 mov     es:[di],al      ;plot it
  335.  
  336. nextcpixt:      inc     si
  337.                 inc     i
  338.                 mov     ah,0
  339.                 mov     al,i
  340.                 mov     di,ax
  341.                 cmp     al,CharW
  342.                 jne     charloop1t
  343.  
  344.                 inc     Y
  345.                 inc     line
  346.                 mov     ax,CHARloc
  347.                 mov     bl,line
  348.                 mov     bh,0
  349.                 add     al,cy[bx]
  350.                 mov     CHARtmp,ax
  351.                 mov     al,line
  352.                 cmp     al,CharH
  353.                 je      cdone
  354.                 jmp     charloop2t
  355.  
  356. cdone:          pop     bp
  357.                 ret     10
  358.  
  359. cbkgrndt:       call    vDUMMY          ;replace this with your
  360.                                         ;video routine or look-up
  361.                                         ;vector to JUMP to ANY
  362.                                         ;video routine
  363.  
  364.                 mov     al,es:[di]      ;check if transparency color
  365.                 cmp     al,tcolor
  366.                 je      skiptrans
  367.  
  368.                 call    vDUMMY          ;replace this with your
  369.                                         ;video routine or look-up
  370.                                         ;vector to JUMP to ANY
  371.                                         ;video routine
  372.  
  373.                 mov     al,bcolor       ;load al w/ background color
  374.                 mov     es:[di],al      ;plot it
  375. skiptrans:      jmp     short nextcpixt
  376.  
  377. XVGAtext        endp
  378.  
  379. vDUMMY          proc    near
  380.                                         ;This routine gets the MCGA
  381.                                         ;320x200x256 mode address
  382.                                         ;for reading and writing a
  383.                                         ;pixel (ie.; character or
  384.                                         ;color to be checked if
  385.                                         ;transparency flag is ON)
  386.  
  387.                                         ;This routine is NOT optimized.
  388.                                         ;It is here for demo purposes
  389.                                         ;only.  You should use your
  390.                                         ;optimized video drivers
  391.                                         ;instead of this - its soooo
  392.                                         ;slow.
  393.                 mov     ax,320
  394.                 mul     y               ;ax=y*320
  395.                 add     ax,si           ;ax has 64KB address
  396.                                         ;si=x
  397.                 mov     di,ax           ;di = 64KB bank address
  398.                 ret
  399. vDUMMY          endp
  400.  
  401.  
  402.  
  403. code            ends
  404.                 end
  405.  
  406.  
  407.  
  408.